//
//  YJ_TabBarController.m
//  YouJoin
//
//  Created by MacBookPro on 15/11/8.
//  Copyright © 2015年 MacBookPro. All rights reserved.
//

#import "YJ_TabBarController.h"
#import "YJ_TabBar.h"
#import "YJ_TabBarButton.h"

@interface YJ_TabBarController ()<YJ_TabBarDelegate>

@end

@implementation YJ_TabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    //添加tabbar
    YJ_TabBar *mainTabBar = [[YJ_TabBar alloc]init];
    mainTabBar.delegate = self;
    CGRect rect = self.tabBar.frame;
    mainTabBar.frame = rect;
    [self.tabBar removeFromSuperview];
    [self.view addSubview:mainTabBar];
    
    for (int i = 0; i<self.viewControllers.count; i++) {
        NSString *name = [NSString stringWithFormat:@"tabbar%d", i + 1];
        NSString *selName = [NSString stringWithFormat:@"tabbar%dSel", i + 1];
        [mainTabBar addTabButtonWithName:name selName:selName];
    }
    
//    self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
//    self.navigationController.navigationBar.barStyle  = UIBarStyleBlack;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark - YJ_TabBar的代理方法
- (void)tabBar:(YJ_TabBar *)tabBar didSelectButtonFrom:(int)from to:(int)to
{
    
    // 选中最新的控制器
    self.selectedIndex = to;
}

@end
